//
//  WFChannelPlateCollectionViewCell.m
//  FAKER
//
//  Created by Jianwei on 15/11/3.
//  Copyright © 2015年 YHLai. All rights reserved.
//

#import "WFChannelPlateCollectionViewCell.h"
//#import "AllHeader.h"
#import "FitHeader.h"
@implementation WFChannelPlateCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createItem];
    }
    return self;
}
- (void)createItem
{

    _picImageView = [[BaseClassImageView alloc]init];
    [CONTENT_VIEW addSubview:_picImageView];
    
    _titleLabel = [[BaseClassLabel alloc]init];
    _titleLabel.textAlignment = 1;
    _titleLabel.font = [UIFont fontWithBold:1 IPhone6sPlus:12 Iphone6s:10 Iphone5s:9 Iphone4s:8];
    [_picImageView addSubview:_titleLabel];
    
    
    //控件位置测试
//    _backImageView.backgroundColor = [UIColor whiteColor];
//    _titleLabel.backgroundColor = [UIColor redColor];
//    _picImageView.backgroundColor = [UIColor greenColor];
}
//- (void)layoutSubviews
//{
//    [super layoutSubviews];

//    _picImageView.frame = CGRectMake(17 * FITWIDTH, 17 * FITWIDTH, 90 * FITWIDTH, 90 * FITWIDTH);
//    _picImageView.contentMode = 0;
//    _picImageView.clipsToBounds = 1;
    
//    _titleLabel.frame = CGRectMake(0, 60 * FITHEIGHT, _picImageView.WIDTH, 20 * FITWIDTH);
//}
- (void)setChannelPlateModel:(WFChannelPlateModel *)channelPlateModel
{
    _channelPlateModel = channelPlateModel;
    
    _titleLabel.text = _channelPlateModel.title;
    
    if (NSUSERDEFAULTS_NIGHT) {
        _titleLabel.textColor = [UIColor grayColor];
    }
    if (_channelPlateModel.pic) {
        [_picImageView sd_setImageWithURL:[NSURL URLWithString:_channelPlateModel.pic] placeholderImage:[UIImage imageNamed:@"PlaceHolder"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
            _picImageView.image = [image imageWithColor:[UIColor RGBFromHexColor:_channelPlateModel.block_color]];
            if (NSUSERDEFAULTS_NIGHT) {
                _picImageView.image = [image imageWithColor:[UIColor lightGrayColor]];
            }
        }];
    }
    else
    {
        _picImageView.image = [UIImage imageNamed:@""];
    }

    //[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:_channelPlateModel.pic]]];
//    _picImageView.image = [_picImageView.image imageWithColor:[UIColor RGBFromHexColor:_channelPlateModel.block_color]];
    
}

@end
